import request from '@/utils/request.js'

//调用注册接口
export const registerService=(registerData)=>{
    //将js对象转为键值对格式数据
    const params=new URLSearchParams();
    for (let key in registerData){
        params.append(key,registerData[key])
    }
    return request({
        method:'post',
        url:'/user/register',
        data:params
    })
}

//调用登录接口
export const loginService=(loginData)=>{
    //将js对象转为键值对格式数据
    const params=new URLSearchParams();
    for (let key in loginData){
        params.append(key,loginData[key])
    }
    return request({
        method:'post',
        url:'/user/login',
        data:params
    })
}

//获取验证码
export const getCaptchaService=()=>{
    return request({
        method:'get',
        url:'/user/captcha'
    })
}

//获取用户详细信息
export const userInfoService=()=>{
    return request({
        method:'get',
        url:'/user/userInfo'
    })
}

//修改用户基本信息
export const updateUserInfoService=(userInfo)=>{
    return request({
        method:'put',
        url:'/user/update',
        data:userInfo
    })
}

//修改用户头像
export const updateAvatarService=(avatarUrl)=>{
    return request({
        method:'patch',
        url:'/user/updateAvatar?avatarUrl='+avatarUrl,
    })
}

//修改用户密码
export const updatePasswordService=(resetPasswordData)=>{
    return request({
        method:'patch',
        url:'/user/updatePwd',
        data:resetPasswordData
    })
}